#include "wx/wxprec.h"
#include "wx/apptrait.h"
#include "wx/unix/execute.h"

// for waitpid()
#include <sys/types.h>
#include <sys/wait.h>

bool wxConsoleAppTraits::CreateEndProcessPipe( wxExecuteData& ( data ) ) {
  return true;
}

bool
wxConsoleAppTraits::IsWriteFDOfEndProcessPipe( wxExecuteData& ( data ),
    int ( fd ) ) {
  return false;
}

void
wxConsoleAppTraits::DetachWriteFDOfEndProcessPipe( wxExecuteData& ( data ) ) {
}

int
wxConsoleAppTraits::WaitForChild( wxExecuteData& execData ) {
  wxASSERT_MSG( execData.flags & wxEXEC_SYNC,wxT( "async execution not supported yet" ) );
  int exitcode = 0;
  if( waitpid( execData.pid, &exitcode, 0 ) == -1 || !WIFEXITED( exitcode ) ) {
    wxLogSysError( _( "Waiting for subprocess termination failed" ) );
  }
  return exitcode;
}

